import {Column, CreateDateColumn, Entity, PrimaryGeneratedColumn, UpdateDateColumn} from "typeorm";
import {ApiProperty} from "@nestjs/swagger";
import {IsOptional} from "class-validator";

@Entity('sys_projects')
export class ProjectEntity {
    @PrimaryGeneratedColumn({ type: 'bigint' })
    id: number

    @Column({ type: 'longtext', name: 'url', comment: '项目地址' })
    url: string

    @Column({ type: 'boolean', name: 'enable', comment: '可用性' })
    enable: boolean

    @Column({ type: 'varchar',length:200,default:true, name: 'name', comment: '项目名' })
    @IsOptional()
    name?: string

    @Column({ type: 'longtext',default:null, name: 'preview_url', comment: '预览图' })
    @IsOptional()
    previewUrl?: string

    @Column({ type: 'longtext', name: 'comment', comment: '项目描述' })
    @IsOptional()
    comment?: string

    @CreateDateColumn({ type: 'timestamp', name: 'create_date', comment: '创建时间',
        precision: 0,default:()=>'CURRENT_TIMESTAMP(0)'})
    @ApiProperty({ description: '创建时间' })
    createDate: Date

    @UpdateDateColumn({ type: 'timestamp', name: 'update_date', comment: '更新时间',
        precision: 0,default:()=>'CURRENT_TIMESTAMP(0)',onUpdate:'CURRENT_TIMESTAMP'
    })
    @ApiProperty({ description: '更新时间' })
    updateDate: Date
}

